package com.ruoyi.crm.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.crm.domain.CrmFeeApplyDetails;
import com.ruoyi.crm.service.ICrmFeeApplyDetailsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 费用申请明细详情Controller
 *
 * @author yanwenliang
 * @date 2024-10-31
 */
@RestController
@RequestMapping("/crm/details")
public class CrmFeeApplyDetailsController extends BaseController
{
    @Autowired
    private ICrmFeeApplyDetailsService crmFeeApplyDetailsService;

    /**
     * 查询费用申请明细详情列表
     */
//    @PreAuthorize("@ss.hasPermi('crm:details:list')")
    @GetMapping("/list")
    public TableDataInfo list(CrmFeeApplyDetails crmFeeApplyDetails)
    {
        startPage();
        List<CrmFeeApplyDetails> list = crmFeeApplyDetailsService.selectCrmFeeApplyDetailsList(crmFeeApplyDetails);
        return getDataTable(list);
    }

    /**
     * 导出费用申请明细详情列表
     */
//    @PreAuthorize("@ss.hasPermi('crm:details:export')")
    @Log(title = "费用申请明细详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CrmFeeApplyDetails crmFeeApplyDetails)
    {
        List<CrmFeeApplyDetails> list = crmFeeApplyDetailsService.selectCrmFeeApplyDetailsList(crmFeeApplyDetails);
        ExcelUtil<CrmFeeApplyDetails> util = new ExcelUtil<CrmFeeApplyDetails>(CrmFeeApplyDetails.class);
        util.exportExcel(response, list, "费用申请明细详情数据");
    }

    /**
     * 获取费用申请明细详情详细信息
     */
//    @PreAuthorize("@ss.hasPermi('crm:details:query')")
    @GetMapping(value = "/{applyDetailsId}")
    public AjaxResult getInfo(@PathVariable("applyDetailsId") String applyDetailsId)
    {
        return success(crmFeeApplyDetailsService.selectCrmFeeApplyDetailsByApplyDetailsId(applyDetailsId));
    }

    /**
     * 新增费用申请明细详情
     */
//    @PreAuthorize("@ss.hasPermi('crm:details:add')")
    @Log(title = "费用申请明细详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CrmFeeApplyDetails crmFeeApplyDetails)
    {
        return toAjax(crmFeeApplyDetailsService.insertCrmFeeApplyDetails(crmFeeApplyDetails));
    }

    /**
     * 修改费用申请明细详情
     */
//    @PreAuthorize("@ss.hasPermi('crm:details:edit')")
    @Log(title = "费用申请明细详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CrmFeeApplyDetails crmFeeApplyDetails)
    {
        return toAjax(crmFeeApplyDetailsService.updateCrmFeeApplyDetails(crmFeeApplyDetails));
    }

    /**
     * 删除费用申请明细详情
     */
//    @PreAuthorize("@ss.hasPermi('crm:details:remove')")
    @Log(title = "费用申请明细详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{applyDetailsIds}")
    public AjaxResult remove(@PathVariable String[] applyDetailsIds)
    {
        return toAjax(crmFeeApplyDetailsService.deleteCrmFeeApplyDetailsByApplyDetailsIds(applyDetailsIds));
    }
}
